]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
volume: Show indicator when microphone is active
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 14 Sep 2019 12:41:08 +0000 (14:41 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Wed, 16 Oct 2019 13:08:20 +0000 (13:08 +0000)
Devices like cameras and microphones are privacy sensitive, as they can
be used to spy on the user. We cannot prevent non-sandboxed apps from
doing that, but as we already track when the microphone is recording,
we can at least show an indicator to make sure it doesn't happen behind
the user's back.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/729

js/ui/status/volume.js

index db8e5a1f1dcfcc80801f640eeb65d0e193dedc17..3d23044dac5d336f48b82a01b2aff772e6fc408c 100644 (file)
@@ -299,6 +299,9 @@ var VolumeMenu = class extends PopupMenu.PopupMenuSection {
         this.addMenuItem(this._output.item);
 
         this._input = new InputStreamSlider(this._control);
+        this._input.item.connect('notify::visible', () => {
+            this.emit('input-visible-changed');
+        });
         this.addMenuItem(this._input.item);
 
         this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
@@ -338,6 +341,10 @@ var VolumeMenu = class extends PopupMenu.PopupMenuSection {
     getMaxLevel() {
         return this._output.getMaxLevel();
     }
+
+    getInputVisible() {
+        return this._input.item.visible;
+    }
 };
 
 var Indicator = class extends PanelMenu.SystemIndicator {
@@ -345,18 +352,24 @@ var Indicator = class extends PanelMenu.SystemIndicator {
         super();
 
         this._primaryIndicator = this._addIndicator();
+        this._inputIndicator = this._addIndicator();
 
         this._control = getMixerControl();
         this._volumeMenu = new VolumeMenu(this._control);
         this._volumeMenu.connect('icon-changed', () => {
             let icon = this._volumeMenu.getIcon();
 
-            if (icon != null) {
-                this.indicators.show();
+            if (icon != null)
                 this._primaryIndicator.icon_name = icon;
-            } else {
-                this.indicators.hide();
-            }
+            this._primaryIndicator.visible = icon !== null;
+        });
+
+        this._inputIndicator.set({
+            icon_name: 'audio-input-microphone-symbolic',
+            visible: this._volumeMenu.getInputVisible(),
+        });
+        this._volumeMenu.connect('input-visible-changed', () => {
+            this._inputIndicator.visible = this._volumeMenu.getInputVisible();
         });
 
         this.menu.addMenuItem(this._volumeMenu);